global forceStartFrame, cameFromScene, lastMouseEvent
-- check if jumping back from another movie
if forceStartFrame > 0 and forceStartFrame < 200000 then
set newStartScene = forceStartFrame
else
set newStartScene = 0
end if
set forceStartFrame = 0
set cameFromScene = 0
clearGlobals
sound stop 1
sound stop 2
set the exitLock = TRUE
CursorStatus(#initialize)
global gAuthoring
set gAuthoring = TRUE -- AUT: set false when packaging the runtime projector
global gQuitPressed
set gQuitPressed = FALSE
InitGlossary() -- initiate glossary events
--
global gEventList
SetupDatabases() -- store global pointers to items
BuildAnimationKeyFrameList()
global gRecompileLists
if the controlDown then -- shiftDown
set gRecompileLists = true
else
set gRecompileLists = false
end if
--òò
if gRecompileLists then
BuildEventList() -- load all events of this CD-ROM
SortEventList() -- sort events in the list
BuildLocatorList()
-- AUT: sorting event list seems to inappropriately re-arrange
-- links that straddle over scenes (look at 4123 pre- and post- sort)
DumpListsToCast()
else
global gEventList, GlossaryList, gLocatorList
set gEventList = rebuildEventList()
-- set gEventList = value(the text of field "Compiled*Event*List")
set GlossaryList = value(the text of field "Compiled*Glossary*Items")
set gLocatorList = value(the text of field "Compiled*Locator*Items")
end if
PrepGlossaryList()
--
global gNavObj
set gNavObj = birth(script "navigation object")
global gFileSuffix
if gAuthoring then -- AUT: load authoring handlers
set gFileSuffix = ".DIR"
-- InitAuthoringTools()
else
set gFileSuffix = ".DXR" -- change this to .EXE or .DXR eventually
end if
if newStartScene > 0 then -- coming back from demo movie...need to restore values
set oldDelim = the itemDelimiter
set the itemDelimiter = ";"
set startScene = newStartScene
set prefLine = line 1 of field "SavePrefsInfo"
set theVol = item 1 of prefLine
set theDelay = item 2 of prefLine
set thePlatform = item 3 of prefLine
set theMode = item 4 of prefLine
set theMusicOn = item 5 of prefLine
global gPresTimeList
set gPresTimeList = value(item 6 of prefLine)
InitPrefs(theVol,theDelay,thePlatform,theMode,theMusicOn) -- reset prefs to saved values
set the itemDelimiter = oldDelim
else
set startScene = 10000 -- AUT: the ID of the first scene
InitPrefs() -- initialize global preferences
end if
checkMainMenuButton()
set lastMouseEvent = the ticks
if the shiftDown then
addProp((the history of gNavObj), startScene, [0,0]) -- add goto point to history
set startScene = 81000
end if
JumpSequence(startScene)
--JumpSequence(95000) -- for debugging individual scenes
CursorStatus(#reset)
end startTMOMovie
--
on JumpSequence myScene
-- put #JumpSequence && myScene && the movieName
global gNavObj
set the sceneID of gNavObj = string(myScene)
LoadSeq(gNavObj, myScene)
ChangeScene(gNavObj, myScene)
end JumpSequence
--
on CursorStatus myStatus
if myStatus = #initialize then
global busyCast, busyCastMask, busyIndex, lastBusyTick
set busyCast = the number of cast "beachball 01"
set busyCastMask = the number of cast "beachball mask"
set busyIndex = -1
set lastBusyTick = the ticks
else if myStatus = #reset then
cursor 0
end if
end CursorStatus
--
on CursorBusy
global busyCast, busyCastMask, busyIndex, lastBusyTick
if the ticks - lastBusyTick > 3 then
set lastBusyTick = the ticks
set busyIndex = (busyIndex+1) mod 4
cursor [busyCast+busyIndex,busyCastMask]
-- put #cursor && busyCast+busyIndex
end if
end CursorBusy
--
-- basic frame script: check events and rollovers every default exitFrame
on exitFrame
global gMode, lastMouseEvent
if gMode = #Demo then return
if (the ticks - lastMouseEvent) > (60*60*10) then
GoAttractLoop(#timeOut)
end if
global gNavObj
UpdateEvents(gNavObj) -- update event queue
UpdateRollover(gNavObj)
end
--
on SetupDatabases
global sBirthPtr, tBirthPtr, sDeathPtr, tDeathPtr, castIdPtr, jumpToIdPtr, scriptPtr
set sBirthPtr = 1
set tBirthPtr = 2
set sDeathPtr = 3
set tDeathPtr = 4
set castIdPtr = 5
set jumpToIdPtr = 6
set scriptPtr = 6
end SetupDatabases
--
on BuildAnimationKeyFrameList
-- build list of animation key frames
global gAnimationScreenList
set gAnimationScreenList = [#6:73200,#9:73210,#12:73220,#16:73230,#17:73240,#19:73250,#24:73260,#25:73270,#31:73280,#35:73290,#36:73300,#39:73310,#45:73330,#51:73340,#53:73350,#56:73360,#59:73370,#61:73380,#63:73390,#64:73400,#66:73410,#67:73420,#70:73430,#71:73440,#75:73442,#76:73444,#78:73446,#85:73460,#75:73442,#76:73444,#78:73446,#89:73500,#92:73510,#93:73530,#94:73520,#109:73540,#111:73550]
sort gAnimationScreenList
global gAnimationReturnTime
set gAnimationReturnTime = 0
global gAnimReturnSet
set gAnimReturnSet = FALSE
end BuildAnimationKeyFrameList
--
-- script for creating CD-ROM event list
-- event list is a "list of lists":
-- it stores each sceneID that has special events in it (links to be born, etc)
-- and the necessary info to deal with those links, as stored in cast "dbase*events"
-- to see what it looks like, put gEventList
on BuildEventList
global gEventList, sBirthPtr, jumpToIdPtr
set gEventList = [:]
-- build list of scene events
set myScenes = the text of cast "dbase*navigation"
set sceneCount = the number of lines of myScenes
-- create a list of all scene IDs in the navigation dbase
repeat with i = 1 to sceneCount
CursorBusy()
set myLine = line i of myScenes
addProp gEventList, value("#" & item sBirthPtr of myLine), [ ]
end repeat
-- add list of events to each scene ID
global castIdPtr
set linkstext = the text of cast "dbase*events"
set eventCount = the number of lines of linkstext
repeat with i = 1 to eventCount
CursorBusy()
set myLine = item 1 to 6 of line i of linkstext -- 11/15 NH hack: no label in compiled list
set eventType = item castIdPtr of myLine
if eventType contains "L" then
-- put myLine
FillEvents(myLine) -- link: straddle over scenes until link death
set myID = item jumpToIdPtr of myLine
if myID contains "glossary" then
AddGlossaryItem(myID)
end if
else if eventType contains "B" then
-- put myLine
StraddleBtn(myLine)
else
-- put item sBirthPtr of myLine -- NOTE 11/2: comment out this line after debugged
-- this puts a trail in the message window.
-- The last item is the item that has a problem.
-- traceME
getAProp gEventList, value("#" & item sBirthPtr of myLine)
set ptrList = the result
if not listP(ptrList) then put myLine
add ptrList, myLine
end if
end repeat
end BuildEventList
--
on StraddleBtn whichEvent
global castIdPtr, sBirthPtr, sDeathPtr, tBirthPtr, tDeathPtr, gEventList
-- event is a button: see if we need to straddle it accross multiple scenes
findPos gEventList, value("#" & item sBirthPtr of whichEvent)
set birthPtr = the result
set myDeath = item sDeathPtr of whichEvent
findPos gEventList, value("#" & myDeath)
set deathPtr = the result
-- put whichEvent
-- put birthPtr & "-" & deathPtr
set myEvent = whichEvent
repeat with i = birthPtr to deathPtr
getPropAt gEventList, i
set mySceneID = string(the result)
put mySceneID into item sBirthPtr of myEvent
put mySceneID into item sDeathPtr of myEvent
getAt gEventList, i
set ptrList = the result
add ptrList, myEvent
end repeat
end StraddleBtn
--
on FillEvents whichEvent
global castIdPtr, sBirthPtr, sDeathPtr, tBirthPtr, tDeathPtr, gEventList
-- event is a link: add death time and future occurrences to event que
findPos gEventList, value("#" & item sBirthPtr of whichEvent)
set birthPtr = the result
set myDeath = item sDeathPtr of whichEvent
findPos gEventList, value("#" & myDeath)
set deathPtr = the result
-- put whichEvent && birthPtr & "-" & deathPtr
set myEvent = whichEvent
set deathTime = item tDeathPtr of myEvent
put "-" into item tDeathPtr of myEvent
repeat with i = birthPtr to deathPtr
if i = birthPtr+1 then
put "00000" into item tBirthPtr of myEvent
end if
getPropAt gEventList, i
set mySceneID = string(the result)
put mySceneID into item sBirthPtr of myEvent
getAt gEventList, i
set ptrList = the result
add ptrList, myEvent
end repeat
-- now add kill event at index deathPtr...
put deathTime into item tDeathPtr of myEvent
put "K" into char 1 of item castIdPtr of myEvent
put item tDeathPtr of whichEvent into item tBirthPtr of myEvent
add ptrList, myEvent
end FillEvents
--
on SortEventList
-- places the events within each scene in chronological order
global gEventList
set lastItem = count(gEventList)
repeat with i = 1 to lastItem
getAt gEventList, i
set myList = the result
sort myList
setAt gEventList, i, myList
end repeat
end SortEventList
--
on BuildLocatorList
global gLocatorList
set gLocatorList = [ : ]
set myLocators = the text of cast "dbase*locators"
set numLocators = the number of lines of myLocators
repeat with thisLocNum = 1 to numLocators
set whatToDoList = [ : ]
set thisLoc = line thisLocNum of myLocators
set thisLocID = item 1 of thisLoc
repeat with resultLoc = 2 to (the number of items of thisLoc)
addProp (whatToDoList,item resultLoc of thisLoc, (resultLoc - 1))
end repeat
addProp(gLocatorList, thisLocID, whatToDoList)
end repeat
sortLocatorList
return 1
end BuildLocatorList
--
on SortLocatorList
global gLocatorList
sort gLocatorList
repeat with i in gLocatorList
sort i
end repeat
end sortLocatorList
--
on DumpListsToCast
global gEventList, GlossaryList, gLocatorList
sort GlossaryList
repeat with i = 1 to 10
set currentEventField = "Compiled*Event*List*" & i
set maxNum = count(gEventList)
set thisList = [ : ]
repeat with j = ((70 * (i-1)) + 1) to (i * 70)
cursorBusy()
if j > maxNum then exit repeat
set thisProp = getPropAt(gEventList, j)
set thisVal = getAt(gEventList, j)
addProp(thisList, thisProp, thisVal)
end repeat
put "dumping to cast: " & currentEventField
put thisList into field currentEventField
end repeat
-- put gEventList into field "Compiled*Event*List"
put GlossaryList into field "Compiled*Glossary*Items"
put gLocatorList into field "Compiled*Locator*Items"
end DumpListsToCast
on rebuildEventList
set newEventList = [ : ]
repeat with i = 1 to 10
set currentEventField = "Compiled*Event*List*" & i
set tempList = value(field currentEventField)
set howManyThisTime = count(tempList)
if howManyThisTime > 0 then
repeat with j = 1 to howManyThisTime
set thisProp = getPropAt(tempList, j)
set thisVal = getAt(tempList, j)
addProp(newEventList, thisProp, thisVal)
end repeat
end if
end repeat
return newEventList
end rebuildEventList
--
on InitPrefs forceVolume, forceDelay, forcePlatform, forceMode, forceMusic
global gSoundLevel, K, gAuthoring, gPlatform, gMode, gPresZone
if voidP(forceVolume) then
-- if gAuthoring then
if the machineType = 256 then
SetVolume(2,#InitPrefs)
else
SetVolume(3,#InitPrefs)
end if
else
setVolume(forceVolume,#InitPrefs)
end if
if (the machineType = 256) or (forcePlatform contains "PC") then set gPlatform = #PC
else set gPlatform = #Mac
if (forceDelay >= 1) and (forceDelay <= 9999) then
SetAnimDelay(forceDelay,#InitPrefs)
else
SetAnimDelay(2,#InitPrefs) -- set default delay to medium
end if
if forceMode contains "Presentation" then
set gMode = #Presentation
set gPresZone = #Green
else
set gMode = #Normal
end if
if not voidP(forceMusic) then
if forceMusic <> "0" then setMusicPlaying(#ON,#InitPrefs)
else setMusicPlaying(#OFF,#InitPrefs)
else
SetMusicPlaying(#ON,#InitPrefs) -- aut: set music off (JS 11/15)--back on 12/7(IB)
end if
set the timeOutLength = 60*60*10 -- 10 minutes
set the timeOutScript = "GoAttractLoop(#timeOut)"
end InitPrefs
--
on SetIndicatorPuppets
-- put #SetIndicatorPuppets
global gModeIndSprite, gDelayIndSprite, gMusicIndSprite
-- AUT: the sprite #s of the preference btn level indicators
set gModeIndSprite = 22
set gDelayIndSprite = 47
set gMusicIndSprite = 48
puppetSprite gModeIndSprite, TRUE
puppetSprite gDelayIndSprite, TRUE
puppetSprite gMusicIndSprite, TRUE
global gNavObj
Add (the exitQue of gNavObj, "KillIndicatorPuppets")
-- global gSoundLevel
-- SetSoundIndicator(gSoundLevel)
global gMode
setModeIndicator(gMode)
global K
SetDelayIndicator(K)
global gMusicOn
SetMusicIndicator(gMusicOn)
end SetIndicatorPuppets
--
on KillIndicatorPuppets
global gModeIndSprite, gDelayIndSprite, gMusicIndSprite
puppetSprite gModeIndSprite, FALSE
puppetSprite gDelayIndSprite, FALSE
puppetSprite gMusicIndSprite, FALSE
-- put #KillIndicatorPuppets
end KillIndicatorPuppets
--
on SetVolume myLevel, theCaller
global gSoundLevel -- range of 0 .. 7
set gSoundLevel = value(myLevel)
set the soundLevel = gSoundLevel
global gNavObj
set theVolumeSprite = the volumeSprite of gNavObj
puppetsprite theVolumeSprite,TRUE
set volPictNum = myLevel
if volPictNum > 6 then set volumePictNum = 6
set the castNum of sprite theVolumeSprite = the number of cast ("volume" & volPictNum)
updateStage
if not(theCaller = #InitPrefs) then
SetSoundIndicator(myLevel)
if the machineType = 256 then
set QTCast = the castNum of sprite (the QTMSprite of gNavObj)
if QTCast > 0 then exit
end if
if myLevel >= 6 then
sound playFile 2, "81000a.aif"
else if myLevel >= 2 then
sound playFile 2, "81000b.aif"
else if myLevel >= 1 then
sound playFile 2, "81000c.aif"
else -- myLevel = 0
beep
end if
end if
end SetVolume
--
on SetAnimDelay theValue, theCaller
global K -- timeout delay constant; range of 1,2,3 to 9999
set K = theValue
SetDelayIndicator(K)
end SetAnimDelay
--
on SetMusicPlaying theValue, theCaller
global gMusicOn, gNavObj
if theValue = #ON or theValue contains "ON" then
set gMusicOn = TRUE
global gNavObj
if not(theCaller = #InitPrefs) then
PlaySceneMusic(gNavObj)
end if
else if theValue = #OFF or theValue contains "OFF" then
set gMusicOn = FALSE
set the musicPlaying of gNavObj = FALSE
puppetsound 0
end if
SetMusicIndicator(gMusicOn)
end SetMusicPlaying
--
on SetMusicIndicator myLevel
global gMusicOn, gMusicIndSprite
if gMusicOn then
set the loc of sprite gMusicIndSprite = point(243, 170) -- 18,254)
else
set the loc of sprite gMusicIndSprite = point(243, 210) -- 58,284)
end if
end SetMusicIndicator
--
on SetSoundIndicator myLevel
return -1 --òò
-- global gSoundIndSprite
set defaultX = 18
set defaultY = 74
set IndDeltaX = 40
set IndDeltaY = 30
set volumeList = [0:3,1:2,3:1,6:0]
sort volumeList
findPos volumeList, myLevel
getAt volumeList, the result
set myOffset = the result
-- set the locH of sprite gSoundIndSprite = defaultX + myOffset*IndDeltaX
-- set the locV of sprite gSoundIndSprite = defaultY + myOffset*IndDeltaY
end SetSoundIndicator
--
on setModeIndicator
global gMode, gModeIndSprite
if gMode = #Presentation then
set the loc of sprite gModeIndSprite = point(75, 210)
else
set the loc of sprite gModeIndSprite = point(75, 170)
end if
end setModeIndicator
--
on SetDelayIndicator myLevel
-- put #animDelay && myLevel
global gDelayIndSprite
set defaultX = 412 -- 342
set defaultY = 170 -- 254
set IndDeltaX = 0 -- 38
set IndDeltaY = 40 -- 30
set myList = [1:3,2:2,3:1,9999:0]
sort myList
findPos myList, myLevel
getAt myList, the result
set myOffset = the result
set the locH of sprite gDelayIndSprite = defaultX + myOffset*IndDeltaX
set the locV of sprite gDelayIndSprite = defaultY + myOffset*IndDeltaY
end SetDelayIndicator
--
on Say whatFile
if soundBusy(2) then
sound close 2
updateStage
end if
set soundFileName = string(whatFile & ".AIF")
sound playFile 2, soundFileName
ResetNavTimeout()
put #ResetNavTimeOut
end Say
--
on AddVOExitScript
-- put #AddVOExitScript
global gNavObj
Add (the exitQue of gNavObj), "CloseSoundChannel 2"
end AddVOExitScript
--
on CloseSoundChannel whichChannel
if soundBusy(whichChannel) then
put #CloseSoundChannel && whichChannel
sound close whichChannel
-- updateStage
end if
end CloseSoundChannel
--
on StoreParent jumpToID
global gNavObj
put the sceneID of gNavObj
set the returnSceneID of gNavObj = the sceneID of gNavObj
put jumpToID
LoadSeq(gNavObj, jumpToID)
ChangeScene(gNavObj, jumpToID)
end StoreParent
--
on JumpToSlide
global gNavObj, gAnimationScreenList
set myTime = the movieTime of sprite the QTMSprite of gNavObj
set the movieRate of sprite (the QTMSprite of gNavObj) = 0
set myTime = integer(myTime/60)
--
findPosNear gAnimationScreenList, myTime
set myPos = the result
set myLast = count(gAnimationScreenList)
if myPos > myLast then
set myPos = myLast
end if
getAt gAnimationScreenList, myPos
set myScene = the result
JumpSequence(myScene)
end JumpToSlide
--
on JumpToAnim
global gAnimationScreenList
global gNavObj
set myScene = value(the sceneID of gNavObj)
global gAnimationReturnTime
GetOne(gAnimationScreenList, myScene)
set gAnimationReturnTime = the result
global gAnimReturnSet
set gAnimReturnSet = TRUE
set myScene = "73000" -- AUT: hardwired return scene for the animation
JumpSequence(myScene)
end JumpToAnim
--
on HandleKeyPress
set keyPressed = the keyCode
-- AUT: disable thise one for golden master:
-- CheckSpaceBarPressed(keyPressed)
--
-- trap exit shortcut
set period = 47
set Q = 12
if ((the keyCode = period OR the keyCode = Q) AND the commandDown) then
global gQuitPressed
-- if gQuitPressed then
Quit -- second time you are pressing quit, so exit immediately
-- else
-- set myScene = 90000 -- AUT: hardwired sceneID of the exit scene
-- JumpSequence(myScene)
-- set gQuitPressed = TRUE
-- end if
end if
end HandleKeyPress
--
on CheckSpaceBarPressed keyPressed
set spaceBar = 49
if keyPressed = spaceBar then
global gNavObj
set myScene = the sceneID of gNavObj
alert "Current sequence ID:" && myScene
end if
end CheckSpaceBarPressed
--
on PreloadScene whichScene
global gNavObj
if whichScene = #current then
-- put #preloadcurrent && the sceneID of gNavObj
set curScene = the sceneID of gNavObj
set startFrame = string(curScene)
set endFrame = string(curScene & "end")
else if whichScene = #next then
-- load the next scene into memory
set nextScene = the nextlink of gNavObj
if integerP(nextScene) and (nextScene > 0) then
-- this is to account for the possibility of nextScene
-- being a handler instead of an integer scene number
set startFrame = 0
else
set startFrame = string(nextScene)
set endFrame = string(nextScene & "end")
end if
else
set startFrame = string(whichScene)
set endFrame = string(whichScene & "end")
end if
if startFrame > 0 then
set memNeeded = ramNeeded(startFrame, endFrame)
if memNeeded >= the freebytes then
-- not enough memory to load scene, dump other stuff first
unloadStartToCurrent(memNeeded)
end if
preload startFrame, endFrame
end if
-- put #preload & whichScene && startFrame & "-" & endFrame & "; loaded:" && the result
end PreloadScene
--
on UnloadStartToCurrent memNeeded
if voidP(memNeeded) or memNeeded = 0 then set memNeeded = (2048*1024) -- 2 Megs
set preMemory = string(the freeBytes/1024 & "KB")
set startFrame = 1
set endFrame = the frame-1
if the freebytes < memNeeded then
-- don't unload if 2 Megs or more still available
unLoad startFrame, endFrame
end if
set myResult = the result
set postMemory = string(the freeBytes/1024 & "KB")